#include <bits/stdc++.h>
//I hate CCF!
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll m,n,t,a[114514];
void dfs(ll dep,string chos){
    if(dep==n+1){
        ll res=0;
        for(ll i=1;i<=n;i++){
            for(int j=i-1;j;j--){
                if(chos[i-1]==chos[j-1]){
                    if(a[i]==a[j])res+=a[i];
                    break;
                }
            }
        }
        m=max(m,res);
        return;
    }
    dfs(dep+1,chos+"1");
    dfs(dep+1,chos+"0");
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i];
        m=0;
        dfs(1,"");
        cout<<m<<endl;
    }
    return 0;
}
